package com.angel.infrastructure.db.mapper;

import com.angel.infrastructure.db.po.HelpInfoPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*
 * 更新关注微信公众号： 为了offer
 * @author parkin
 * @description
 * @date 2021/11/17
 */
@Mapper
public interface HelpInfoMapper extends BaseMapper<HelpInfoPO> {
    // 查询评论数量较小的前十的求助信息
    @Select("SELECT " +
            "hi.* " +
            "FROM " +
            "help_info hi " +
            "LEFT JOIN ( SELECT help_id, count( voice_id ) voiceCount FROM voice_info GROUP BY help_id ORDER BY voiceCount LIMIT #{size} ) AS t " +
            "ON hi.help_id=t.help_id  ORDER BY hi.help_id LIMIT #{size}"
            )
    List<HelpInfoPO> getHelpInfosOrderByVoiceNumberAndDesc(int size);
}
